﻿using System.Collections.Generic;
using System.Data;
namespace WPFExcelReport
{
    public partial class VAPARTE
    {
        VMEVAR _AE05;
        public VMEVAR AE05
        {
            get
            {
                if (_AE05 == null) _AE05 = new VMEVAR();
                return _AE05;
            }
        }

        public void Insert(DataRow _dwAPK)
        {
            InsertAPARTE(_dwAPK, app.company);
            TBMain.Rows.InsertAt(_dwAPK, 0);
        }
        public void COPYAPE(Dictionary<string, object> pm)
        {
            dwData = TBMain.NewRow();
            dwData["APAEMANDANT"] = app.Mandant;
            dwData["APAEANRKRS"] = (string)pm["NRKRS"];
            dwData["APAEALFDNR"] = (string)pm["LFDNR"];
            dwData["APAEAFOLGE"] = (string)pm["FOLGE"];
            dwData["APAEAEVOR"] = (string)pm["EVOR"];
            DARE02(dwData);
            dwData = TBMain.NewRow(); 
            dwData["APAEMANDANT"] = app.Mandant;
            dwData["APAEANRKRS"] = (string)pm["BNRKRS"];
            dwData["APAEALFDNR"] = (string)pm["BLFDNR"];
            dwData["APAEAFOLGE"] = (string)pm["BFOLGE"];
            dwData["APAEAEVOR"] = (string)pm["BEVOR"]; 
            SResult = QKSZ04(dwData);
           
            foreach (DataRow dwAE in SResult.Tables[0].Rows)
            {
                dwAE["APAEANRKRS"] = (string)pm["NRKRS"];
                dwAE["APAEALFDNR"] = (string)pm["LFDNR"];
                dwAE["APAEAFOLGE"] = (string)pm["FOLGE"];
                dwAE["APAEAEVOR"] = (string)pm["EVOR"]; 
                InsertAPARTE(dwAE);
            }
        }
        public void NEWAPE(Dictionary<string, object> pm)
        {
            SResult = AE05.LOADAE05(pm);
            dwData = TBMain.NewRow();
            SetUpNewRow(ref dwData);
            dwData["APAEANRKRS"] = (string)pm["ANRKRS"];
            dwData["APAEALFDNR"] = (string)pm["ALFDNR"];
            dwData["APAEAFOLGE"] = (string)pm["AFOLGE"];
            dwData["APAEAEVOR"] = (string)pm["AEVOR"];
            DARE02(dwData);
            foreach (DataRow dwAE in SResult.Tables[0].Rows)
            {
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["APAEANRKRS"] = (string)pm["ANRKRS"];
                dwData["APAEALFDNR"] = (string)pm["ALFDNR"];
                dwData["APAEAFOLGE"] = (string)pm["AFOLGE"];
                dwData["APAEAEVOR"] = (string)pm["AEVOR"];
                dwData["APAEMODNR"] = dwAE["MEVMODNR"];
                dwData["APAEEINSTNR"] = dwAE["MEVEINSTNR"];
                dwData["APAEWERTX"] = dwAE["MEVWERTX"];
                dwData["APAEWERTN"] = dwAE["MEVWERTN"];
                TBMain.Rows.InsertAt(dwData, 0);
                InsertAPARTE(dwData, app.company);
            } 
        }
        public void DLAPE(Dictionary<string, object> pm)
        {

            dwData = TBMain.NewRow();
            dwData["APAEMANDANT"] = app.Mandant;
            dwData["APAEANRKRS"] = (string)pm["ANRKRS"];
            dwData["APAEALFDNR"] = (string)pm["ALFDNR"];
            dwData["APAEAFOLGE"] = (string)pm["AFOLGE"];
            dwData["APAEAEVOR"] = (string)pm["AEVOR"];
            DARE02(dwData);  
        }
    }
    public partial class VAPARTE
    {
        public string APAEANRKRS { get { if (dwMaster == null) return ""; return dwMaster["APAEANRKRS"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEANRKRS"] = value; OnPropertyChanged("APAEANRKRS", value); } } //lENGth 2
        public string APAEALFDNR { get { if (dwMaster == null) return ""; return dwMaster["APAEALFDNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEALFDNR"] = value; OnPropertyChanged("APAEALFDNR", value); } } //lENGth 6
        public string APAEAFOLGE { get { if (dwMaster == null) return ""; return dwMaster["APAEAFOLGE"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEAFOLGE"] = value; OnPropertyChanged("APAEAFOLGE", value); } } //lENGth 3
        public string APAEAEVOR { get { if (dwMaster == null) return ""; return dwMaster["APAEAEVOR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEAEVOR"] = value; OnPropertyChanged("APAEAEVOR", value); } } //lENGth 4
        public string APAEMODNR { get { if (dwMaster == null) return ""; return dwMaster["APAEMODNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEMODNR"] = value; OnPropertyChanged("APAEMODNR", value); } } //lENGth 3
        public string APAEEINSTNR { get { if (dwMaster == null) return ""; return dwMaster["APAEEINSTNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEEINSTNR"] = value; OnPropertyChanged("APAEEINSTNR", value); } } //lENGth 3
        public string APAEWERTX { get { if (dwMaster == null) return ""; return dwMaster["APAEWERTX"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEWERTX"] = value; OnPropertyChanged("APAEWERTX", value); } } //lENGth 16
        public string APAEWERTN { get { if (dwMaster == null) return ""; return dwMaster["APAEWERTN"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEWERTN"] = value; OnPropertyChanged("APAEWERTN", value); } } //lENGth 16

        #region======ColumnSchema==========
        /*
                 public string APAEMANDANT { get { if (dwMaster == null) return ""; return dwMaster["APAEMANDANT"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEMANDANT"] = value; OnPropertyChanged("APAEMANDANT", value); } } //lENGth 2
                 public string APAEWERK { get { if (dwMaster == null) return ""; return dwMaster["APAEWERK"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEWERK"] = value; OnPropertyChanged("APAEWERK", value); } } //lENGth 3
                 public string APAEPROGNR { get { if (dwMaster == null) return ""; return dwMaster["APAEPROGNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEPROGNR"] = value; OnPropertyChanged("APAEPROGNR", value); } } //lENGth 4
                 public string APAEEINAUS { get { if (dwMaster == null) return ""; return dwMaster["APAEEINAUS"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEEINAUS"] = value; OnPropertyChanged("APAEEINAUS", value); } } //lENGth 1
                 public string APAEREZEPTKZ { get { if (dwMaster == null) return ""; return dwMaster["APAEREZEPTKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEREZEPTKZ"] = value; OnPropertyChanged("APAEREZEPTKZ", value); } } //lENGth 1
                 public string APAEREZEPTNR { get { if (dwMaster == null) return ""; return dwMaster["APAEREZEPTNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEREZEPTNR"] = value; OnPropertyChanged("APAEREZEPTNR", value); } } //lENGth 10
                 public string APAEREZEPTST { get { if (dwMaster == null) return ""; return dwMaster["APAEREZEPTST"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEREZEPTST"] = value; OnPropertyChanged("APAEREZEPTST", value); } } //lENGth 1
                 public string APAEWERKZ { get { if (dwMaster == null) return ""; return dwMaster["APAEWERKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEWERKZ"] = value; OnPropertyChanged("APAEWERKZ", value); } } //lENGth 14
                 public string APAEFAKTOR { get { if (dwMaster == null) return ""; return dwMaster["APAEFAKTOR"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEFAKTOR"] = value; OnPropertyChanged("APAEFAKTOR", value); } } //lENGth 2
                 public string APAESTAKZ { get { if (dwMaster == null) return ""; return dwMaster["APAESTAKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAESTAKZ"] = value; OnPropertyChanged("APAESTAKZ", value); } } //lENGth 1
                 public string APAEMODEIN { get { if (dwMaster == null) return ""; return dwMaster["APAEMODEIN"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEMODEIN"] = value; OnPropertyChanged("APAEMODEIN", value); } } //lENGth 1
                 public double APAEAENDZL { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["APAEAENDZL"].ToString()); } set { if (dwMaster == null) return; dwMaster["APAEAENDZL"] = value; OnPropertyChanged("APAEAENDZL", value); } } //lENGth 0
                 public string APAEAENDBEN { get { if (dwMaster == null) return ""; return dwMaster["APAEAENDBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEAENDBEN"] = value; OnPropertyChanged("APAEAENDBEN", value); } } //lENGth 8
                 public double APAEAENDDAT { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["APAEAENDDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["APAEAENDDAT"] = value; OnPropertyChanged("APAEAENDDAT", value); } } //lENGth 0
                 public string APAENEUBEN { get { if (dwMaster == null) return ""; return dwMaster["APAENEUBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAENEUBEN"] = value; OnPropertyChanged("APAENEUBEN", value); } } //lENGth 8
                 public double APAENEUDAT { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["APAENEUDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["APAENEUDAT"] = value; OnPropertyChanged("APAENEUDAT", value); } } //lENGth 0
                 public string APAEFILLER { get { if (dwMaster == null) return ""; return dwMaster["APAEFILLER"].ToString(); } set { if (dwMaster == null) return; dwMaster["APAEFILLER"] = value; OnPropertyChanged("APAEFILLER", value); } } //lENGth 33
        */
        #endregion
    }
}

